
// 日期格式化
function formatDate(timestamp, format = 'YYYY-mm-dd HH:MM:SS') {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  // 24小时制，直接使用getHours()
  const hours = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const seconds = String(date.getSeconds()).padStart(2, '0');

  return format
    .replace('YYYY', year)
    .replace('mm', month)
    .replace('dd', day)
    .replace('HH', hours)
    .replace('MM', minutes)
    .replace('SS', seconds);
}

module.exports = {
  formatDate
};